package com.ruoyi.web.controller.memberCoupon;


import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.StoredValueCardRuleOperationLog;
import com.ruoyi.system.service.IStoredValueCardRuleOperationLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 储值卡规则操作记录 Controller
 *
 * @author ruoyi
 * @date 2025-05-22
 */
@Api(tags="储值卡规则操作记录")
@RestController
@RequestMapping("/system/storedValueCardRuleOperationLog")
public class StoredValueCardRuleOperationLogController extends BaseController
{
    @Autowired
    private IStoredValueCardRuleOperationLogService storedValueCardRuleOperationLogService;

    /**
     * 通过操作门店，操作类型，储值卡编码，操作开始时间和操作结束时间查询储值卡规则操作记录列表
     */
    @ApiOperation("通过操作门店，操作类型，储值卡编码，操作开始时间和操作结束时间查询储值卡规则操作记录列表")
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) String operatorStore, @RequestParam(required = false) String operationType, @RequestParam(required = false) String cardCode, @RequestParam(required = false) Date operationStartTime, @RequestParam(required = false) Date operationEndTime)
    {
        startPage();
        List<StoredValueCardRuleOperationLog> list = storedValueCardRuleOperationLogService.selectStoredValueCardRuleOperationLogListByConditions(operatorStore,operationType,cardCode,operationStartTime,operationEndTime);
        return getDataTable(list);
    }

    /**
     * 导出储值卡规则操作记录列表
     */
    @ApiOperation("导出储值卡规则操作记录列表")
    @PreAuthorize("@ss.hasPermi('system:log:export')")
    @Log(title = "储值卡规则操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestParam(required = false) String operatorStore, @RequestParam(required = false) String operationType, @RequestParam(required = false) String cardCode, @RequestParam(required = false) Date operationStartTime, @RequestParam(required = false) Date operationEndTime)
    {
        List<StoredValueCardRuleOperationLog> list = storedValueCardRuleOperationLogService.selectStoredValueCardRuleOperationLogListByConditions(operatorStore,operationType,cardCode,operationStartTime,operationEndTime);
        ExcelUtil<StoredValueCardRuleOperationLog> util = new ExcelUtil<StoredValueCardRuleOperationLog>(StoredValueCardRuleOperationLog.class);
        util.exportExcel(response, list, "储值卡规则操作记录数据");
    }

    /**
     * 通过id获取储值卡规则操作记录详细信息
     */
    @ApiOperation("通过id获取储值卡规则操作记录详细信息")
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(storedValueCardRuleOperationLogService.selectStoredValueCardRuleOperationLogById(id));
    }

    /**
     * 新增储值卡规则操作记录
     */
    @ApiOperation("新增储值卡规则操作记录")
    @PreAuthorize("@ss.hasPermi('system:log:add')")
    @Log(title = "储值卡规则操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StoredValueCardRuleOperationLog storedValueCardRuleOperationLog)
    {
        return toAjax(storedValueCardRuleOperationLogService.insertStoredValueCardRuleOperationLog(storedValueCardRuleOperationLog));
    }

    /**
     * 修改储值卡规则操作记录
     */
    @ApiOperation("修改储值卡规则操作记录")
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "储值卡规则操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StoredValueCardRuleOperationLog storedValueCardRuleOperationLog)
    {
        return toAjax(storedValueCardRuleOperationLogService.updateStoredValueCardRuleOperationLog(storedValueCardRuleOperationLog));
    }

    /**
     * 通过id批量删除储值卡规则操作记录信息
     */
    @ApiOperation("通过id批量删除储值卡规则操作记录信息")
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "储值卡规则操作记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(storedValueCardRuleOperationLogService.deleteStoredValueCardRuleOperationLogByIds(ids));
    }
}
